package network.UDP;

import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;

/**
 * @author zxl
 * @version 1.0
 * @date 2021/10/22 10:41
 */
public class Client {
    public static void main(String[] args) throws Exception {
        //建立连接
        DatagramSocket socket = new DatagramSocket();
        //建立数据包
        String a = "你好";
        DatagramPacket datagramPacket = new DatagramPacket(a.getBytes(), 0, a.getBytes().length, InetAddress.getLocalHost(), 9002);
        //发送包
        socket.send(datagramPacket);
        //关闭流
        socket.close();
    }
}
